<%-- 
    Document   : Stock Barang
    Created on : 26 Nov 13, 19:01:17
    Author     : PUTIK ALWENA
--%>

<%@page import="Model.Barang"%>
<%@page import="java.util.List"%>
<%@page import="java.util.logging.Logger"%>
<%@page import="java.util.logging.Level"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Statement"%>
<%@page import="Model.DatabaseConnect"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Halaman Lihat Stok</title>
    </head>
    <body background="background.jpg">
        <form action="StokBarangControl.jsp" method="post" name="stok">
            <table width="1009" border="0">
                <tr>
                    <td width="406" height="28" align="center" valign="middle"><h2><a href="PesananBarang.jsp">Daftar Pesanan</a></h2></td>
                    <td width="286" align="center" valign="middle"><h2><a href="StokBarang.jsp">Stock Barang</a></h2></td>
                    <td width="295" align="center" valign="middle"><h2><a href="PesanBarang.jsp">Pesan Barang</a></h2></td>
                    <td width="295" align="center" valign="middle"><h2><a href="KirimBarang.jsp">Pengiriman Barang</a></h2></td>
                    <td width="295" align="center" valign="middle"><h2><a href="TerimaBarang.jsp">Terima Barang</a></h2></td> 
                    <td width="295" align="center" valign="middle"><h2> <a href="Login.jsp">Logout</a></h2></td>
                </tr>
                <td width="200" valign="top"><h2>Stock Barang </h2> 
                    <select name="kodetoko" style="background-color: aquamarine">
                        <option value="none">Pilih Kantor Cabang</option>
                        <option value="ck01">Toko Circle K</option>
                        <option value="ck02">Toko A</option>
                        <option value="ck03">Toko B</option>
                        <option value="ck04">Toko C</option>
                    </select>
                </td>
                <tr>
                    <td><input type="submit" value="Lihat" /></td>
                </tr>
                <%  Model.Barang cekstok = (Model.Barang) session.getAttribute("stok");
                    if (cekstok == null) {
                        cekstok = new Model.Barang();
                        session.setAttribute("stok", cekstok);
                    }
                    Model.Barang stokck = new Barang();
                    cekstok.setKodeToko((String) request.getParameter("kodetoko"));
                    String pilih = request.getParameter("kodetoko");

                    if (pilih.matches("ck01")) {
                        List<Barang> liststok = stokck.tampilstok();
                %>

                <tr>
                <table align="center" width="463" height="75" border="0">
                    <b><p style="color : purple "align="center"> STOK CIRCLE K</p></b>

                    <th bgcolor="#999999" width="150"><div align="center">Kode Barang</div> </th>
                    <th bgcolor="#999999" width="350"><div align="center">Nama Barang</div> </th>
                    <th bgcolor="#999999" width="200"><div align="center">Jenis Barang</div></th>
                    <th bgcolor="#999999" width="150"><div align="center">Jumlah</div></th>
                    <th bgcolor="#999999" width="250"><div align="center">Harga </div></th>
                    <tr>

                        <%

                            for (Barang term : liststok) {
                        %>
                        <td bgcolor="#FFFFFF"><div align="center"><%=term.getKodeBarang()%></div></td>
                        <td bgcolor="#FFFFFF"><div align="center"><%=term.getNamaBarang()%></div></td>
                        <td bgcolor="#FFFFFF"><div align="center"><%=term.getJenisBarang()%></div></td>
                        <td bgcolor="#FFFFFF"><div align="center"><%=term.getJumlahBarang()%></div></td>
                        <td bgcolor="#FFFFFF"><div align="center"><%=term.getHargaBarang()%></div></td>
                    </tr>
                    <%
                        }
                    } else if (pilih.matches("ck02")) {
                        List<Barang> liststoka = stokck.tampilstoka();
                    %>
                    <tr>
                    <table align="center" width="463" height="75" border="0">

                        <b> <p style="color : purple "align="center"> STOK TOKO A</p></b>
                        <th bgcolor="#999999" width="150"><div align="center">Kode Barang</div> </th>
                        <th bgcolor="#999999" width="350"><div align="center">Nama Barang</div> </th>
                        <th bgcolor="#999999" width="200"><div align="center">Jenis Barang</div></th>
                        <th bgcolor="#999999" width="150"><div align="center">Jumlah</div></th>
                        <th bgcolor="#999999" width="250"><div align="center">Harga </div></th>
                        <tr>
                            <%
                                for (Barang terma : liststoka) {
                            %>
                            <td bgcolor="#FFFFFF"><div align="center"><%=terma.getKodeBarang()%></div></td>
                            <td bgcolor="#FFFFFF"><div align="center"><%=terma.getNamaBarang()%></div></td>
                            <td bgcolor="#FFFFFF"><div align="center"><%=terma.getJenisBarang()%></div></td>
                            <td bgcolor="#FFFFFF"><div align="center"><%=terma.getJumlahBarang()%></div></td>
                            <td bgcolor="#FFFFFF"><div align="center"><%=terma.getHargaBarang()%></div></td>
                            <%
                                }
                            } else if (pilih.matches("ck03")) {
                                List<Barang> liststokb = stokck.tampilstokb();
                            %>
                        <tr>
                        <table align="center" width="463" height="75" border="0">

                            <b><p style="color : purple "align="center"> STOK TOKO B</p></b>
                            <th bgcolor="#999999" width="150"><div align="center">Kode Barang</div> </th>
                            <th bgcolor="#999999" width="350"><div align="center">Nama Barang</div> </th>
                            <th bgcolor="#999999" width="200"><div align="center">Jenis Barang</div></th>
                            <th bgcolor="#999999" width="150"><div align="center">Jumlah</div></th>
                            <th bgcolor="#999999" width="250"><div align="center">Harga </div></th>
                            <tr>
                                <%
                                    for (Barang termb : liststokb) {
                                %>
                                <td bgcolor="#FFFFFF"><div align="center"><%=termb.getKodeBarang()%></div></td>
                                <td bgcolor="#FFFFFF"><div align="center"><%=termb.getNamaBarang()%></div></td>
                                <td bgcolor="#FFFFFF"><div align="center"><%=termb.getJenisBarang()%></div></td>
                                <td bgcolor="#FFFFFF"><div align="center"><%=termb.getJumlahBarang()%></div></td>
                                <td bgcolor="#FFFFFF"><div align="center"><%=termb.getHargaBarang()%></div></td>
                                <%
                                    }
                                } else if (pilih.matches("ck04")) {
                                    List<Barang> liststokc = stokck.tampilstokc();
                                %>
                            <tr>
                            <table align="center" width="463" height="75" border="0">

                                <b><p style="color : purple "align="center"> STOK TOKO C</p></b>
                                <th bgcolor="#999999" width="150"><div align="center">Kode Barang</div> </th>
                                <th bgcolor="#999999" width="350"><div align="center">Nama Barang</div> </th>
                                <th bgcolor="#999999" width="200"><div align="center">Jenis Barang</div></th>
                                <th bgcolor="#999999" width="150"><div align="center">Jumlah</div></th>
                                <th bgcolor="#999999" width="250"><div align="center">Harga </div></th>
                                <tr>
                                    <%
                                        for (Barang termc : liststokc) {
                                    %>
                                    <td bgcolor="#FFFFFF"><div align="center"><%=termc.getKodeBarang()%></div></td>
                                    <td bgcolor="#FFFFFF"><div align="center"><%=termc.getNamaBarang()%></div></td>
                                    <td bgcolor="#FFFFFF"><div align="center"><%=termc.getJenisBarang()%></div></td>
                                    <td bgcolor="#FFFFFF"><div align="center"><%=termc.getJumlahBarang()%></div></td>
                                    <td bgcolor="#FFFFFF"><div align="center"><%=termc.getHargaBarang()%></div></td>
                                    <%
                                            }
                                        }
                                    %>
                            </table>
                            </form>
                            </body>
                            </html>
